//
//  BottomAlertActionView.m
//  YouinRTCDemo
//
//  Created by 潘欣 on 2025/6/11.
//

#import "BottomAlertActionView.h"
#import <LSTPopView/LSTPopView.h>
@interface BottomAlertActionView ()
@property (nonatomic,weak) LSTPopView *popView;
//禁言
@property (nonatomic,strong)UIButton *silentButton;
//直播数据
@property (nonatomic,strong)UIButton *dataButton;
// 黑名单
@property (nonatomic,strong)UIButton *blockButton;
//取消
@property (nonatomic,strong)UIButton *cancelButton;
@end

@implementation BottomAlertActionView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        
        
        self.silentButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.silentButton addTarget:self action:@selector(buttonsAction:) forControlEvents:UIControlEventTouchUpInside];
        self.silentButton.tag = 100;
        [self.silentButton setTitle:@"禁言列表" forState:UIControlStateNormal];
        [self.silentButton setTitleColor:RYColorForHex(@"#333333") forState:UIControlStateNormal];
        self.silentButton.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
        [self addSubview:self.silentButton];
        
         
        
        
        [self.silentButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 48));
            make.top.mas_equalTo(self);
        }];
        
        
        
        self.dataButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.dataButton setTitle:@"数据统计" forState:UIControlStateNormal];
        [self.dataButton addTarget:self action:@selector(buttonsAction:) forControlEvents:UIControlEventTouchUpInside];
        self.dataButton.tag = 101;
        [self.dataButton setTitleColor:RYColorForHex(@"#333333") forState:UIControlStateNormal];
        self.dataButton.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
        [self addSubview:self.dataButton];
        
        [self.dataButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 48));
            make.top.mas_equalTo(self.silentButton.mas_bottom);
        }];
        
        
//        添加上边线
       CALayer *topBorder = [CALayer layer];
       topBorder.backgroundColor = RYColorForHex(@"#F5F8FF").CGColor; // 设置线条颜色
       topBorder.frame = CGRectMake(0, 0, SCREEN_WIDTH, 1);
       [self.dataButton.layer addSublayer:topBorder];

       // 添加下边线
       CALayer *bottomBorder = [CALayer layer];
       bottomBorder.backgroundColor = RYColorForHex(@"#F5F8FF").CGColor; // 设置线条颜色
       bottomBorder.frame = CGRectMake(0, 47, SCREEN_WIDTH, 1);
       [self.dataButton.layer addSublayer:bottomBorder];
        
       
        self.blockButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.blockButton setTitle:@"黑名单" forState:UIControlStateNormal];
        [self.blockButton addTarget:self action:@selector(buttonsAction:) forControlEvents:UIControlEventTouchUpInside];
        self.blockButton.tag = 102;
        [self.blockButton setTitleColor:RYColorForHex(@"#333333") forState:UIControlStateNormal];
        self.blockButton.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
        [self addSubview:self.blockButton];
        
        [self.blockButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 48));
            make.top.mas_equalTo(self.dataButton.mas_bottom);
        }];
        
        UILabel *label = [[UILabel alloc] init];
        label.backgroundColor = RYColorForHex(@"#f6f8fe");
        [self addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 20));
            make.top.mas_equalTo(self.blockButton.mas_bottom);
        }];
        
        self.cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.cancelButton setTitle:@"取消" forState:UIControlStateNormal];
        [self.cancelButton addTarget:self action:@selector(cancelButtonsAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.cancelButton setTitleColor:RYColorForHex(@"#888888") forState:UIControlStateNormal];
        self.cancelButton.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightRegular];
        [self addSubview:self.cancelButton];
        
        [self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 48));
            make.top.mas_equalTo(label.mas_bottom);
        }];
        
    }
    return self;
}

- (void)buttonsAction:(UIButton *)senders
{
    if ([self.deledate respondsToSelector:@selector(bottomActions:)]) {
        [self.deledate bottomActions:senders];
    }
}

- (void)cancelButtonsAction:(UIButton *)sender
{
    [self hideView];
}

-(void)showView
{
    LSTPopView *popView = [LSTPopView initWithCustomView:self
                                                popStyle:LSTPopStyleSmoothFromBottom
                                            dismissStyle:LSTDismissStyleSmoothToBottom];

    popView.hemStyle = LSTHemStyleBottom;
    popView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.5];
    LSTPopViewWK(popView)
    popView.popDuration = 0.5;
    popView.dismissDuration = 0.5;
    popView.isClickFeedback = YES;
    popView.rectCorners = UIRectCornerTopLeft | UIRectCornerTopRight;
    popView.cornerRadius = 15;
    popView.sweepStyle = LSTSweepStyleY_Positive;
    popView.dragStyle = LSTDragStyleY_Positive;
    popView.sweepDismissStyle = LSTSweepDismissStyleSmooth;
    popView.bgClickBlock = ^{
        NSLog(@"点击了背景");
        [wk_popView dismiss];
    };
    self.popView = popView;

    [popView pop];
}

-(void)hideView;
{
    [self.popView dismiss];
}
-(void)dealloc
{
    NSLog(@"dealloc");
}

@end
